﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YiSha.Util;

namespace YiSha.Entity.Business
{
    /// <summary>
    /// 档案表
    /// </summary>
    [Table("BsPerson")]
    public class PersonEntity : BaseExtensionEntity
    {



        /// <summary>
        /// 真实姓名
        /// </summary>
        [Description("真实姓名")]
        public string RealName { get; set; }

        /// <summary>
        /// 真实姓名简拼
        /// </summary>
        [Description("真实姓名简拼")]
        public string RealNameEn { get; set; }
        /// <summary>
        /// 身份证号码
        /// </summary>
        [Description("身份证号码")]
        public string IdCard { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        [Description("性别")]
        public int Gender { get; set; }


        [NotMapped]
        public string GenderText {
            get { if (Gender == 1)
                {
                    return "男";
                }
                else if (Gender == 2)
                {
                    return "女";
                }
                else
                {
                    return "未填写";
                }
            }
        }

        /// <summary>
        /// 生日
        /// </summary>
        [Description("生日")]
        public DateTime Birthday { get; set; }

        [NotMapped]
        public int Age
        {
            get {
                return DateTime.Now.Year - Birthday.Year;
            }
        }

        /// <summary>
        /// 手机号
        /// </summary>
        [Description("手机号")]
        public string Mobile { get; set; }
        /// <summary>
        /// 联系人姓名
        /// </summary>
        [Description("联系人姓名")]
        public string ContactsName { get; set; }
        /// <summary>
        /// 联系人手机号
        /// </summary>
        [Description("联系人手机号")]
        public string ContactsMobile { get; set; }

        /// <summary>
        /// 身份类别
        /// </summary>
        [Description("身份类别")]
        public EnumOccupation OccupationValue { get; set; }



        /// <summary>
        /// 身份类别
        /// </summary>
      [NotMapped]
        public string OccupationTest { 
            get{
               return OccupationValue.ToString();
            }
                }

        /// <summary>
        /// 工作单位
        /// </summary>
        [Description("工作单位")]
        public string WorkUnit { get; set; }

        /// <summary>
        /// 家庭住址
        /// </summary>
        [Description("家庭住址")]
        public string Address { get; set; }



        /// <summary>
        /// 所属店铺
        /// </summary>
        [Description("所属店铺")]
        [JsonConverter(typeof(StringJsonConverter))]
        public long DepartmentId { get; set; }

        [NotMapped]
        public string DepartmentName { get; set; }

    }

    #region 枚举值人员
    public enum EnumOccupation
    {
        学生 = 1,
        上班族 = 2,
        自由职业 = 3,
        退休 = 4,
        其他 = 0
    }

    #endregion
}